package com.yanqu.road.server.channelserver.cmd.union;

import com.yanqu.road.entity.player.UserBaseInfo;
import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.ChannelTonBingProto;
import com.yanqu.road.pb.player.PlayerProto;
import com.yanqu.road.server.channelserver.cmd.ChannelCommand;
import com.yanqu.road.server.channelserver.manager.user.ChannelUserMgr;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.N_CHANNEL_QUERY_USER_RESP, desc = "")
public class ChannelQueryUserRespCmd extends ChannelCommand {

    private ChannelTonBingProto.CTonBingGoGetUserBaseInfoRespMsg reqMsg;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        reqMsg = ChannelTonBingProto.CTonBingGoGetUserBaseInfoRespMsg.parseFrom(packet.getBytes());
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        for(ChannelTonBingProto.CTonBingGoGetUserBaseInfoTempMsg bangMsg : reqMsg.getUsersList()){
            // 更新userBaseInfo
            UserBaseInfo userBaseInfo = PlayerBasePb.parseBaseUserInfo(bangMsg.getUserBaseInfo());
            ChannelUserMgr.updateUserBaseInfo(bangMsg.getUserId(), userBaseInfo);
        }
    }

    @Override
    public void sendData() {

    }
}
